# Codes to replicate tables and figures in the main text and the appendix
# based on narratives mined from the U.S. Congressional Record.

# Before running this file, please consider the README.

# Computational requirements:
# 16GB RAM and one core

# Total computing time:
# Approximately 15 minutes

source venv/bin/activate

cd ./code

export PYTHONHASHSEED=0

# Examples of narratives for sentences, topics, and entities.
python3 print_descriptive_tables.py

# Plot the "War on Terror" narratives
python3 plot_war_on_terror_narratives.py

# Plot partisan and emotional narratives.
python3 get_partisan_narratives_horizontal.py
python3 plot_partisan_narratives_horizontal.py
python3 get_sentiment_narratives_horizontal.py
python3 plot_sentiment_narratives_horizontal.py

# Plot top 10 politically neutral and partisan narratives.
python3 plot_partisan_narratives_vertical.py

# Plot narrative graphs for the U.S. Congressional Record, Republicans, and Democrats.
python3 plot_worldviews.py

# Table of frequent narratives and plots of their prevalence over time.
python3 plot_individual_narratives.py

# Visualize the clustering of entities via PCA with 2 components.
python3 clusters_pca_visualization.py

# Analysis of divisive narratives relative to entity divisiveness.
python3 divisive_narratives_entities.py

# Tables for the most frequent (named / clustered) entities and their associated phrases.
python3 inspect_entities.py

# Footnote on the prediction accuracy for party affiliation using narratives vs. entities.
python3 prepare_document_term_matrices.py
python3 predict_partisanship_narratives.py
python3 predict_partisanship_entities.py

# Footnote on the number of narratives per word or character between Republicans and Democrats.
python3 get_narratives_per_words_or_chars.py

# Implementation of the PMI score and a skip-gram model for narratives.
python3 narrative_embeddings.py